package com.heu.blood.storge.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.heu.blood.dict.entity.DictTypeEntity;
import org.apache.logging.log4j.util.Strings;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heu.blood.common.utils.PageUtils;
import com.heu.blood.common.utils.Query;

import com.heu.blood.storge.dao.DictTemplateEntryDao;
import com.heu.blood.storge.entity.DictTemplateEntryEntity;
import com.heu.blood.storge.service.DictTemplateEntryService;


@Service("dictTemplateEntryService")
public class DictTemplateEntryServiceImpl extends ServiceImpl<DictTemplateEntryDao, DictTemplateEntryEntity> implements DictTemplateEntryService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        DictTemplateEntryEntity dictTemplateEntryEntity = new DictTemplateEntryEntity();

        if (Strings.isNotBlank((String) params.get("dictType"))){
            dictTemplateEntryEntity.setDictType((String) params.get("dictType")); // 字典类型
        }
        LambdaQueryWrapper<DictTemplateEntryEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Strings.isNotBlank(dictTemplateEntryEntity.getDictType()), DictTemplateEntryEntity::getDictType, dictTemplateEntryEntity.getDictType());
        IPage<DictTemplateEntryEntity> page = this.page(
                new Query<DictTemplateEntryEntity>().getPage(params),
                queryWrapper
        );

        return new PageUtils(page);
    }

}